<!DOCTYPE html>





<html class="theme-next gemini use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.3.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    save_scroll: false,
    copycode: {"enable":false,"show_result":false,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="description" content="jenkins前端自动部署入门由于前端项目打包后是静态资源，不需要进程守护。一般地，前端项目使用jenkins来进行自动部署，包括打包、测试等一系列流程 由于 jenkins是基于java环境运行的，所以首先需要安装java环境 参考：https://jingyan.baidu.com/article/375c8e190c1f9525f2a22931.html 下载1、下载地址：https:/">
<meta name="keywords" content="jenkins,部署">
<meta property="og:type" content="article">
<meta property="og:title" content="jenkins前端自动部署入门">
<meta property="og:url" content="http://yoursite.com/2019/12/06/2019/11/jenkins前端自动部署入门/index.html">
<meta property="og:site_name" content="淡退">
<meta property="og:description" content="jenkins前端自动部署入门由于前端项目打包后是静态资源，不需要进程守护。一般地，前端项目使用jenkins来进行自动部署，包括打包、测试等一系列流程 由于 jenkins是基于java环境运行的，所以首先需要安装java环境 参考：https://jingyan.baidu.com/article/375c8e190c1f9525f2a22931.html 下载1、下载地址：https:/">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://desk-fd.zol-img.com.cn/t_s1024x768c5/g5/M00/0C/02/ChMkJ13V9q6IOSp_AAPNPlvQOwwAAvV_QJYgfoAA81W947.jpg">
<meta property="og:updated_time" content="2019-12-08T13:06:26.454Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="jenkins前端自动部署入门">
<meta name="twitter:description" content="jenkins前端自动部署入门由于前端项目打包后是静态资源，不需要进程守护。一般地，前端项目使用jenkins来进行自动部署，包括打包、测试等一系列流程 由于 jenkins是基于java环境运行的，所以首先需要安装java环境 参考：https://jingyan.baidu.com/article/375c8e190c1f9525f2a22931.html 下载1、下载地址：https:/">
<meta name="twitter:image" content="https://desk-fd.zol-img.com.cn/t_s1024x768c5/g5/M00/0C/02/ChMkJ13V9q6IOSp_AAPNPlvQOwwAAvV_QJYgfoAA81W947.jpg">
  <link rel="canonical" href="http://yoursite.com/2019/12/06/2019/11/jenkins前端自动部署入门/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>jenkins前端自动部署入门 | 淡退</title>
  








  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div class="container sidebar-position-left">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">淡退</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">---脂肪肝患者</p>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-about">
      
    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
      </li>
    
  </ul>

</nav>
  <div class="site-search">
    
  <div class="popup search-popup">
  <div class="search-header">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <div class="search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="search-input">
    </div>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>
  <div id="search-result"></div>
</div>


  </div>
</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/12/06/2019/11/jenkins前端自动部署入门/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="淡退">
      <meta itemprop="description" content="欢迎你的到来！">
      <meta itemprop="image" content="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1565847089857&di=2bb546a711f57b819a4dbf3584c66392&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F458af12108c4da0f1cf4fe8e2713a458898e332b28196-jdjJ3j_fw658">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="淡退">
    </span>
      <header class="post-header">
        
          <i class="fa fa-thumb-tack"></i>
          <font color=7D26CD>置顶</font>
        

        
          <h1 class="post-title" itemprop="name headline">jenkins前端自动部署入门

            
          </h1>
        

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-12-06 23:10:17" itemprop="dateCreated datePublished" datetime="2019-12-06T23:10:17+08:00">2019-12-06</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-12-08 21:06:26" itemprop="dateModified" datetime="2019-12-08T21:06:26+08:00">2019-12-08</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/js/" itemprop="url" rel="index"><span itemprop="name">js</span></a></span>

                
                
              
            </span>
          

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <div class="post-gallery" itemscope itemtype="http://schema.org/ImageGallery">
            <div class="post-gallery-row">
              <img src="https://desk-fd.zol-img.com.cn/t_s1024x768c5/g5/M00/0C/02/ChMkJ13V9q6IOSp_AAPNPlvQOwwAAvV_QJYgfoAA81W947.jpg" itemprop="contentUrl">
            
          

          </div>
        </div>
        <a id="more"></a>

<h2 id="jenkins前端自动部署入门"><a href="#jenkins前端自动部署入门" class="headerlink" title="jenkins前端自动部署入门"></a>jenkins前端自动部署入门</h2><p>由于前端项目打包后是静态资源，不需要进程守护。一般地，前端项目使用jenkins来进行自动部署，包括打包、测试等一系列流程</p>
<p>由于 jenkins是基于java环境运行的，所以首先需要安装java环境</p>
<p>参考：<br><a href="https://jingyan.baidu.com/article/375c8e190c1f9525f2a22931.html" target="_blank" rel="noopener">https://jingyan.baidu.com/article/375c8e190c1f9525f2a22931.html</a></p>
<h4 id="下载"><a href="#下载" class="headerlink" title="下载"></a>下载</h4><p>1、下载地址：<a href="https://jenkins.io/download，" target="_blank" rel="noopener">https://jenkins.io/download，</a></p>
<p>下载最后war包, 下载完成后进入下载后的目录，在<code>cmd</code>中输入 <code>java -jar jenkins.war</code> 然后在页面输入<code>localhost:8080</code></p>
<h4 id="初始化"><a href="#初始化" class="headerlink" title="初始化"></a>初始化</h4><p>　　启动jenkins服务后，可以在8080端口访问到jenkins<br><img src="https://pic.xiaohuochai.site/blog/jenkins1.png" alt></p>
<p>然后在服务器的指定目录找到密码登录</p>
<p>/var/lib/jenkins/secrets/initialAdminPassword</p>
<p>按照默认配置安装插件 </p>
<p><img src="https://pic.xiaohuochai.site/blog/jenkins2.png" alt></p>
<p>等待插件安装完成</p>
<p><img src="https://pic.xiaohuochai.site/blog/jenkins3.png" alt></p>
<p>创建一个管理员账户，完成配置后，就可以登录 Jenkins 了</p>
<p><img src="https://pic.xiaohuochai.site/blog/jenkins4.png" alt></p>
<h4 id="安装插件"><a href="#安装插件" class="headerlink" title="安装插件"></a>安装插件</h4><p>下面来安装nodejs插件<br><img src="https://pic.xiaohuochai.site/blog/jenkins6.png" alt></p>
<p>可以看到，Jenkins提供了丰富的插件供开发者使用，找到需要的[NodeJS Plugin]，勾选后点击安装即可</p>
<p><img src="https://pic.xiaohuochai.site/blog/jenkins7.png" alt></p>
<blockquote>
<p>可能会出现网络不好或者被墙的情况，可以换一下域（百度一下）</p>
</blockquote>
<h4 id="配置任务"><a href="#配置任务" class="headerlink" title="配置任务"></a>配置任务</h4><ol>
<li>安装好github钩子以及nodejs插件后，接下来开始配置任务</li>
</ol>
<p>　　点击创建一个新任务，填写任务名称，构建的项目类型可根据实际情况进行选择，本次选择第一种即可<br>　　<br><img src="https://pic.xiaohuochai.site/blog/jenkins5.png" alt></p>
<ol start="2">
<li>配置基础信息</li>
</ol>
<p><img src="https://pic.xiaohuochai.site/blog/jenkins12.png" alt></p>
<ol start="3">
<li><p>往下拉，看到源码管理，点选Git，依然填写博客对应的Repo地址<br><img src="https://pic.xiaohuochai.site/blog/jenkins13.png" alt></p>
</li>
<li><p>继续往下拉，在构建触发器单击增加构建步骤，在弹出的下拉菜单中选择<code>Execute shell。勾选GitHub hook trigger for GITScm polling</code>。构建环境选择nodejs</p>
</li>
</ol>
<p><img src="https://pic.xiaohuochai.site/blog/jenkins14.png" alt></p>
<ol start="5">
<li>构建过程<br>一般地，构建过程，输入如下 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm install &amp;&amp;</span><br><span class="line">npm run build</span><br></pre></td></tr></table></figure>

</li>
</ol>
<h3 id="问题处理："><a href="#问题处理：" class="headerlink" title="问题处理："></a>问题处理：</h3><ol>
<li><p>假如证书有问题的话会报错：<br><img src="https://img2018.cnblogs.com/blog/1406304/201905/1406304-20190527105223189-1051377169.png" alt><br>可以点击：  <a href="https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json" target="_blank" rel="noopener">https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</a></p>
<p>滑动到最后，配置修改地址，将https改成http，</p>
</li>
</ol>
<p><a href="http://updates.jenkins.io/update-center.json" target="_blank" rel="noopener">http://updates.jenkins.io/update-center.json</a></p>
<p>或者</p>
<p><a href="https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json" target="_blank" rel="noopener">https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</a></p>
<p>然后点击submit-&gt;checknow</p>
<ol start="2">
<li>插件管理页面提示：There were errors <code>checking the update sites:IOException:Unable to tunnel through proxy.Proxy returins &quot;HTTP/1.1 400&quot;</code><br><img src="https://img2018.cnblogs.com/blog/1406304/201905/1406304-20190524095823763-636781851.png" alt><br>解决办法和第一个是一样的。</li>
</ol>
<p>参考文档：</p>
<ul>
<li><a href="https://blog.csdn.net/lykio_881210/article/details/88557728" target="_blank" rel="noopener">Jenkins+GitHub集成接口测试环境部署</a></li>
<li><a href="https://www.cnblogs.com/grey-wolf/p/8716662.html" target="_blank" rel="noopener">jenkins实战（一）：war安装及插件安装</a></li>
<li><a href="https://www.cnblogs.com/imyalost/p/8677345.html" target="_blank" rel="noopener">jenkins简单安装及配置（Windows环境）</a></li>
<li><a href="https://blog.csdn.net/GISuuser/article/details/100121237" target="_blank" rel="noopener">Jenkins安装与插件安装连接超时问题</a></li>
<li><a href="https://blog.csdn.net/u011922006/article/details/88187060" target="_blank" rel="noopener">jenkins+github集成自动化测试环境搭建（1）-jenkins和github安装</a></li>
</ul>

    </div>

    
    
    
        
      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/jenkins/" rel="tag"># jenkins</a>
            
              <a href="/tags/部署/" rel="tag"># 部署</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/2019/11/22/2019/11/Decorator装饰器 学习笔记/" rel="next" title="Decorator装饰器 学习笔记">
                  <i class="fa fa-chevron-left"></i> Decorator装饰器 学习笔记
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1565847089857&di=2bb546a711f57b819a4dbf3584c66392&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F458af12108c4da0f1cf4fe8e2713a458898e332b28196-jdjJ3j_fw658"
      alt="淡退">
  <p class="site-author-name" itemprop="name">淡退</p>
  <div class="site-description motion-element" itemprop="description">欢迎你的到来！</div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">14</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">5</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">10</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>



        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#jenkins前端自动部署入门"><span class="nav-number">1.</span> <span class="nav-text">jenkins前端自动部署入门</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#下载"><span class="nav-number">1.0.1.</span> <span class="nav-text">下载</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#初始化"><span class="nav-number">1.0.2.</span> <span class="nav-text">初始化</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#安装插件"><span class="nav-number">1.0.3.</span> <span class="nav-text">安装插件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#配置任务"><span class="nav-number">1.0.4.</span> <span class="nav-text">配置任务</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#问题处理："><span class="nav-number">1.1.</span> <span class="nav-text">问题处理：</span></a></li></ol></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <!--<i class="fa fa-user"></i>-->
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">淡退</span>
</div>
<!--
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.3.0</div>
-->
        








        
      </div>
    </footer>
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
      </div>

    

  </div>

  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script>
  <script src="/js/motion.js?v=7.3.0"></script>


  <script src="/js/affix.js?v=7.3.0"></script>
  <script src="/js/schemes/pisces.js?v=7.3.0"></script>



<script src="/js/next-boot.js?v=7.3.0"></script>




  















  <script src="/js/local-search.js?v=7.3.0"></script>














  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script>
<script src="/js/post-details.js?v=7.3.0"></script>


  <script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
</body>
</html>
